package com.cneiu.ppms.web.action;

import com.cneiu.ppms.web.base.BaseController;
import com.cneiu.ppms.web.model.TransModel;
import com.cneiu.ppms.web.service.TransService;
import com.jfinal.plugin.activerecord.Page;
/**
 * 变压器Controller
 * @author zhaokf
 * @date 2013-04-19
 */
public class TransController extends BaseController
{
	/**
	 * 获取page limit得到变压器列表
	 */
	public void list(){
	
		Page<TransModel> Trans = TransService.list(this.getParams());
		if (null != Trans){
			renderGrid(Trans.getTotalRow(), Trans.getList());
		}else{
			renderAjax(false, TransService.getError());
		}
	}

	/**
	 * 添加变压器
	 */
	public void add(){
		try{
			boolean isNotError = true;
			if (!TransService.isAdd(this.getParams())){
				isNotError = false;
			}
			renderAjax(isNotError, TransService.getError());
		}
		catch (Exception e){}

	}

	/**
	 * 编辑变压器
	 */
	public void edit(){
		try{
			boolean isNotError = true;
			if (TransService.isUpdate(this.getParams())){
				isNotError = false;
			}
			renderAjax(isNotError, TransService.getError());
		}
		catch (Exception e){}
	}
	
	/**
	 * 删除变压器
	 */
	public void delete(){
		try{
			boolean isNotError = true;
			if (TransService.isDelete(this.getParams())){
				isNotError = false;
			}
			renderAjax(isNotError, TransService.getError());
		}
		catch (Exception e){
		}
	}
}
